package tat.domain;

import java.util.HashMap;
import java.util.Map;


public class RequirementList {


	private Map<String, Requirement> requirements;

	public RequirementList(){
		requirements = new HashMap<String, Requirement>();
	}

    public boolean containsDerivedRequirement(final Relation relation) {
        return requirements.containsKey(relation.name());
    }

    public void removeDerivedRequirement(final Relation relation) {
        Requirement requirement = requirements.get(relation.name());
        remove(requirement);
    }

    public void add(final Requirement requirement) {
    	requirements.put(requirement.value(), requirement);
    }

    public Requirement find(final String requirementText) {
        return requirements.get(requirementText);
    }

    public void remove(final Requirement requirement) {
  		requirements.remove(requirement.value());
    }

    public Requirement[] conferRequirements(){
    	return requirements.values().toArray( new Requirement[requirements.size()]);
    }

    public void remapRequirement(final String oldValue, final Requirement requirement){
    	requirements.remove(oldValue);
    	requirements.put(requirement.value(), requirement);
    }
}
